package tc.jv.task2;

public final class Vectors
{
	public static void sort(Vector v)
	{
		qsort(v, 0, v.size()-1);
	}
	
	private static void qsort(Vector v, int low, int high)
	{
		int i, j;
		double m, temp;
		
		i = low; j = high;
		m = v.get((i + j) / 2);
		do
		{
			while (v.get(i) < m)
				i++;
			while (v.get(j) > m)
				j--;
			if (i <= j)
			{
				temp = v.get(i);
				v.set(i, v.get(j));
				v.set(j, temp);
				i++;
				j--;
			}			
		}
		while (i <= j);
		if (low < j)
			qsort(v, low, j);
		if (i < high)
			qsort(v, i, high);
	}
}
